package com.lzy.product.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.OrderProfitRecordMapperExt;
import com.lzy.product.dtos.BaseDomain;
import com.lzy.product.dtos.statistics.DayProfitParamDto;
import com.lzy.product.dtos.statistics.DayProfitVoDto;
import com.lzy.product.dtos.statistics.OrderProfitRecordDto;
import com.lzy.product.dtos.statistics.TotalProfitVoDto;
import com.lzy.product.entity.OrderProfitRecord;
import com.lzy.product.service.OrderProfitRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单分利记录服务
 * Created by WIN7 on 2017/12/7.
 */
@Service
public class OrderProfitRecordServiceImpl implements OrderProfitRecordService {
    @Autowired
    private OrderProfitRecordMapperExt orderProfitRecordMapperExt;

    @Override
    public Long insert(OrderProfitRecordDto dto) {
        OrderProfitRecord orderProfitRecord = DozerUtils.map(dto, OrderProfitRecord.class);
        return orderProfitRecordMapperExt.insert(orderProfitRecord) > 0 ? orderProfitRecord.getId() : null;
    }

    @Override
    public Boolean update(OrderProfitRecordDto dto) {
        return null;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public OrderProfitRecordDto findById(Long id) {
        return null;
    }

    @Override
    public List<OrderProfitRecordDto> query(OrderProfitRecordDto dto) {
        return null;
    }

    @Override
    public List<OrderProfitRecordDto> findByOrderId(Long orderId) {
        return orderProfitRecordMapperExt.findByOrderId(orderId);
    }

    @Override
    public PageInfo<OrderProfitRecordDto> selectList(Pager pager, OrderProfitRecordDto paramDto) {
        if (pager != null) {
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        }
        List<OrderProfitRecordDto> list = orderProfitRecordMapperExt.selectList(paramDto);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<TotalProfitVoDto> queryTotalProfitList(Pager pager, BaseDomain paramDto) {
        if (pager != null) {
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        }
        List<TotalProfitVoDto> list = orderProfitRecordMapperExt.queryTotalProfitList(paramDto);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<DayProfitVoDto> queryDayProfitList(Pager pager, DayProfitParamDto paramDto) {
        if (pager != null) {
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        }
        List<DayProfitVoDto> list = orderProfitRecordMapperExt.queryDayProfitList(paramDto);
        return new PageInfo<>(list);
    }

    @Override
    public List<DayProfitVoDto> queryDayProfitListNoPage(DayProfitParamDto paramDto) {
        return orderProfitRecordMapperExt.queryDayProfitList(paramDto);
    }


    @Override
    public BigDecimal getQueryProfit(DayProfitParamDto paramDto) {
        return orderProfitRecordMapperExt.getQueryProfit(paramDto);
    }

    @Override
    public BigDecimal getUserTotalProfit() {
        return orderProfitRecordMapperExt.getUserTotalProfit();
    }
}
